package com.hulizuofang.wol.chat.client.ui.loading;

import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.inject.Inject;

public class LoadingPanelPopupImpl extends Composite implements LoadingPanel {
	private AbsolutePanel container;
	private Image image;

	public interface LoadingPanelBundle extends ClientBundle {
		@Source("loading.gif")
		ImageResource loading();
	}
	
	@Inject
	public LoadingPanelPopupImpl() {
		LoadingPanelBundle bundle = GWT.create(LoadingPanelBundle.class);

		container = new AbsolutePanel();
		container.setVisible(false);
		image = new Image(bundle.loading());
		container.add(image);
		
		image.setVisible(false);
		initWidget(container);
	}

	@Override
	public void display(boolean shouldLock) {
		if (shouldLock) {
			image.setVisible(true);
		} else {
			image.setVisible(false);
		}
	}
	
	
}
